#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/1/3 23:13
# @Author  : lizhen
# @Site    : 
# @File    : Time.py
# @Software: PyCharm
import locale
import time

from datetime import date, timedelta, datetime


class Time:
    def __init__(self):
        # COREMODIFIED 时间兼容中文编码
        locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')

    def get_ymd_before(self, day):
        _today = date.today()
        _ymd = datetime.strptime(str(_today), '%Y-%m-%d')
        _ymd = (_ymd + timedelta(days=day)).strftime('%Y-%m-%d')
        return _ymd

    def get_ymd_before_zh(self, day):
        _today = date.today()
        _ymd = datetime.strptime(str(_today), '%Y-%m-%d')
        _ymd = (_ymd + timedelta(days=day)).strftime('%Y年%m月%d日')
        return _ymd

    def get_ymd(self):
        _time = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        return _time

    def get_ymd_num(self):
        _time = time.strftime('%Y%m%d', time.localtime(time.time()))
        return _time

    def get_ymd_zh(self):
        _time = time.strftime('%Y年%m月%d日', time.localtime(time.time()))
        return _time

    def get_y_zh(self):
        _time = time.strftime('%Y年', time.localtime(time.time()))
        return _time

    def get_m_zh(self):
        _time = time.strftime('%m月', time.localtime(time.time()))
        return _time

    def get_d_zh(self):
        _time = time.strftime('%d日', time.localtime(time.time()))
        return _time


mytime = Time()
if __name__ == '__main__':
    print(mytime.get_ymd_before(-1))
    print(mytime.get_ymd_before_zh(-1))
    print(mytime.get_ymd())
    print(mytime.get_ymd_num())
    print(mytime.get_ymd_zh())
    print(mytime.get_y_zh())
    print(mytime.get_m_zh())
    print(mytime.get_d_zh())
